package com.itheima.reggie.common;

/**
 * 基于ThreadLocal封装的工具类，用于保存和获取当前线程登陆登录的用户id
 * @author Xiao
 * @date 2021/9/24
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    /**
     * 设置id
     * @param id
     */
    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }
    /**
     * 获取id
     * @return
     */
    public static Long getCurrentId() {
        return threadLocal.get();
    }
}
